﻿<UserControl x:Class="XDraw.Controls.GradientStopEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
  <DockPanel>
    <ToolBarTray Orientation="Vertical" DockPanel.Dock="Right">
      <ToolBar>
        <Button Content="+" Click="Add_Click"/>
        <Button Content="-" Click="Remove_Click"/>
        <Separator/>
        <Button Content="/\" Click="Up_Click"/>
        <Button Content="\/" Click="Down_Click"/>
      </ToolBar>
    </ToolBarTray>

    <DataGrid x:Name="_DataGrid" x:FieldModifier="private" 
              ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=GradientStops}"
              SelectedItem="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=SelectedGradientStop, Mode=TwoWay}"
              AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" CanUserSortColumns="False">
      <DataGrid.Columns>
        <DataGridTemplateColumn Header="Offset" Width="60">
          <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
              <xctk:DoubleUpDown Value="{Binding Path=Offset, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                 Increment="0.1"/>
            </DataTemplate>
          </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
        <DataGridTemplateColumn Header="Color" Width="60">
          <DataGridTemplateColumn.CellTemplate>
            <DataTemplate>
              <xctk:ColorPicker SelectedColor="{Binding Path=Color, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
            </DataTemplate>
          </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
      </DataGrid.Columns>
    </DataGrid>
  </DockPanel>
</UserControl>
